package com.kexio.dynamic;

import com.kexio.dynamic.config.DynamicConfigAutoConfiguration;
import com.kexio.dynamic.datasource.config.DynamicDataSourceConfig;
import com.kexio.dynamic.feature.FeatureToggleAutoConfiguration;
import com.kexio.dynamic.permission.DynamicPermissionAutoConfiguration;
import com.kexio.dynamic.properties.DynamicProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

/**
 * Dynamic Starter 自动配置类
 * 
 * @author Kexio Team
 * @since 1.0.0
 */
@AutoConfiguration
@ComponentScan(basePackages = "com.kexio.dynamic")
@EnableConfigurationProperties(DynamicProperties.class)
@ConditionalOnProperty(prefix = "kexio.dynamic", name = "enabled", havingValue = "true", matchIfMissing = true)
@AutoConfigureAfter(name = "com.kexio.core.CoreAutoConfiguration")
@Import({
    DynamicConfigAutoConfiguration.class,
    DynamicDataSourceConfig.class,
    DynamicPermissionAutoConfiguration.class,
    FeatureToggleAutoConfiguration.class
})
public class DynamicAutoConfiguration {
    
    private static final Logger log = LoggerFactory.getLogger(DynamicAutoConfiguration.class);
    
    public DynamicAutoConfiguration() {
        log.info("==> Kexio Dynamic Starter 自动配置已启用");
    }
}
